#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


void Test1()
{
	/*for (int i = 0; i == 1; i++)
	{
		cout << i << endl;
	}*/
	/*int i = 10;
	printf("%-5d%d", i, i);*/
	/*const char* str1 = "hello world";
	char str2[] = "world";
	printf("%-5.3s%5.2s", str1, str2);*/
}

void Test2()
{
	int a = 10;
	const int* p1 = &a;
	int const * p2 = &a;
	int* const p3 = &a;
	p1++;
	p2++;
	//p3++;
	cout << a << endl;
}

int MoreThanHalfNum_Solution(vector<int>& numbers) {
    // write code here
    sort(numbers.begin(), numbers.end());
    int count_max = 0;
    vector<int>::iterator p_max;
    auto left = numbers.begin();
    auto right = numbers.begin();
    while (right != numbers.end())
    {
        int count = 0;
        while (right != numbers.end() && *left == *right)
        {
            count++;
            right++;
        }
        if (count > count_max)
        {
            count_max = count;
            p_max = left;
        }
        left = right;
    }
    return *p_max;
}

void Test3()
{
    int arr[5] = { 2,2,2,3,4 };
    vector<int> v(arr, arr+5);
    cout << MoreThanHalfNum_Solution(v) << endl;
}

int main()
{
	Test3();
	return 0;
}